class Product < ActiveRecord::Base
    has_many :warehouse_positions
    has_many :warehouses, :through => :warehouse_positions
    has_many :documents_positions
    has_many :documents, :through => :documents_positions

    validates_presence_of :name, :code, :unit, :net_price, :vat_rate
	validates_uniqueness_of :name, :case_sensitive => false
	validates_uniqueness_of :code
    validates_numericality_of :net_price, :greater_than_or_equal_to => 0
    validates_numericality_of :vat_rate, :greater_than_or_equal_to => 0, :less_than_or_equal_to => 100
end
